{% extends 'base.html' %}
{% load humanize %}
{% block page-content %}
{% include 'nav_cat_bar.html' %}

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>{{tip}} </h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="#">Config option 1</a>
                            </li>
                            <li><a href="#">Config option 2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                      <div class="col-sm-4 m-b-xs">
                          <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#dept_add"><i class="icon-cogs"></i>增加部门</button>
                      </div>
                  </div>
                {% if error %}
                    <div class="alert alert-warning text-center">{{ error }}</div>
                {% endif %}
                {% if add_info %}
                    <div class="alert alert-success text-center">{{ add_info }}</div>
                {% endif %}
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <th class="text-center">部门</th>
                                <th class="text-center">用户</th>
                                <th class="text-center">备注</th>
                                <th class="text-center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for depat,user in data.items %}
                                  <tr class="text-center">
                                      <!-- <td>{{forloop.counter}}</td> -->
                                    <td>{{depat}}</td>
                                    <td>
                                        {% for u in user %}
                                            {{u}}
                                        {%endfor%}
                                    </td>
                                    {% for info in dept_info %}
                                        {% ifequal info.name depat %}
                                            <td>{{ info.comment }}</td>
                                        {% endifequal %}
                                    {% endfor %}
                                    <td>
                                    <a href="/manager/dept_edit/?dept_name={{depat}}"><span class="glyphicon glyphicon-pencil"></span></a>
                                    <a href="/manager/dept_list/?dept_name={{depat}}&action=delete"><span class="glyphicon glyphicon-trash" style="color:red" onclick="return confirm('确认删除吗？')"></span></a>
                                    </td>

                                  </tr>
                                 {% endfor %}
                            </tbody>
                        </table>
                       <div class="col-sm-6">
                            <div class="dataTables_info" id="editable_info" role="status" aria-live="polite">
                                  Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries
                            </div>
                        </div>
                           {% include 'paginator.html' %}
                        </div>
                </div>
            </div>
        </div>

    </div>
</div>
<div class="modal fade" id="dept_add" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="exampleModalLabel" align="center">添加部门</h4>
      </div>
      <div class="modal-body">
<form id="dept_form" method="post" class="form-horizontal" action="">
	<div class="form-group">
		<label for="group_name" class="col-sm-2 control-label">部门<span class="red-fonts">*</span></label>
		<div class="col-sm-8">
			<input id="dept_name" name="dept_name" placeholder="Group name" type="text" class="form-control" >
		</div>
	</div>
	<div class="hr-line-dashed"></div>
	<div class="form-group">
		<label for="comment" class="col-sm-2 control-label">备注</label>
		<div class="col-sm-8">
			<input id="dept_comment" name="dept_comment" placeholder="Comment" type="text" class="form-control">
		</div>
	</div>
</form>
</div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="submit" class="btn btn-primary" form="dept_form" formmethod="post" formaction="{% url 'dept_list' %}" name="action" value="add">确定</button>
      </div>
    </div>
  </div>
</div>


{% endblock %}
